package cn.tedu.spring.begin;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class UserTest {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        ApplicationContext context=new ClassPathXmlApplicationContext
                ("bean.xml");
        User user=(User) context.getBean("user");
        System.out.println("user="+user);
        user.add();

        User user2=new User();
        System.out.println("user2:="+user2);
        user2.add();

        Class cl=Class.forName("cn.tedu.spring.begin.User");
        User user3=(User) cl.newInstance();
        System.out.println("user3="+user3);
        user3.add();
    }
}
